﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QL_NOI_TRU
{
    public partial class frmNhapDMThuoc : DevExpress.XtraEditors.XtraForm
    {
        public frmNhapDMThuoc()
        {
            InitializeComponent();
        }

        private void frmNhapDMThuoc_Load(object sender, EventArgs e)
        {
            var kn = new Ketnoi(frmDangnhap.stringConn);
            gridControl1.DataSource = kn.ExcuteQuery("select * from THUOC");
        }

        private void btThemThuoc_Click(object sender, EventArgs e)
        {
            obThuoc ob = new obThuoc { MATHUOC = tbMaThuoc.Text, TENTHUOC = tbTenThuoc.Text, GIATHUOC = tbGia.Text };

            if (ob.MATHUOC != "")
            {
                string a = String.Format("Insert into THUOC VALUES('{0}',N'{1}','{2}')", ob.MATHUOC, ob.TENTHUOC, ob.GIATHUOC);
                var kn = new Ketnoi(frmDangnhap.stringConn);
                kn.ExcuteNonQuery(a);
                btRefreshThuoc_Click(null, null);
            }
            else
            {
                MessageBox.Show("chưa nhập mã thuốc!");
            }
        }

        private void btRefreshThuoc_Click(object sender, EventArgs e)
        {
            tbMaThuoc.Text = "";
            tbTenThuoc.Text = "";
            tbGia.Text = "";
        }
    }
}